//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Spreadsheet.Expressions;
using OpenLS.Spreadsheet.Extensibility;

namespace OpenLS.Spreadsheet
{
    partial class Range: IRange
    {
        #region IRange Members

        IEnumerable<ICell> IRange.GetNonEmptyCells()
        {
            foreach (var cell in GetNonEmptyCells() )
            {
                yield return cell;
            }
        }

        ICell IRange.FirstCell
        {
            get { return FirstCell; }
        }

        int IRange.ColumnSpan
        {
            get { return ColumnSpan; }
        }

        int IRange.RowSpan
        {
            get { return RowSpan; }
        }

        ICell IRange.this[int row, int column]
        {
            get { return this[row, column]; }
        }

        int IRange.RowIndex
        {
            get { return Row; }
        }

        int IRange.ColumnIndex
        {
            get { return Column; }
        }

        int IRange.Areas
        {
            get
            {
                if (this is CompositeRange)
                    return ((CompositeRange) this).Ranges.Count;
                return 1;
            }
        }

        #endregion

        #region IRange Members


        IRange IRange.GetRowRange(int index, RangeType type)
        {
            return GetRowRange(index, type);
        }

        IRange IRange.GetColumnRange(int index, RangeType type)
        {
            return GetColumnRange(index, type);
        }

        #endregion

        IRange ICellEnumerator.ToRange()
        {
            return this;
        }
    }
}
